﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DPLAB.IPAMS.BO.Interface;

namespace DPLAB.IPAMS.DataEntities
{
    public class Loader
    {
        private readonly IPAMSDataSet ipamsDataSet;

        public Loader(IPAMSDataSet ipamsDataSet)
        {
            this.ipamsDataSet = ipamsDataSet;
        }

        public IList<ITax> CreateTaxes()
        {
            var taxes = new List<ITax>();
            taxes.AddRange(from p in ipamsDataSet.Tax.AsEnumerable()
                       select (ITax)new Tax(p));
            return taxes;
        }
    }
    
    // simple wrapper that implements IEnumerable<T>
    public class LinqList<T>: IEnumerable<T>, IEnumerable
    {
        IEnumerable items;

        public LinqList(IEnumerable items)
        {
            this.items = items;
        }

        #region IEnumerable<DataRow> Members
        IEnumerator<T> IEnumerable<T>.GetEnumerator()
        {
            foreach (T item in items)
                yield return item;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            IEnumerable<T> ie = this;
            return ie.GetEnumerator();
        }
        #endregion
    }
}
